const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const jqueryRouter = require('./controller/jqueryRouter.js');
const javascriptRouter = require('./controller/javascriptRouter.js');
const videoRouter = require('./controller/videoRouter.js');
const oppRouter = require('./controller/oppRouter.js');
const ajaxRouter = require('./controller/ajaxRouter.js');
const uploadRouter = require('./controller/uploadRouter.js');
const exampleClassifyRouter = require('./controller/interFace/common.js');
const favicon = require('serve-favicon');
const compression = require('compression')

app.use(bodyParser.urlencoded({ extended: false }))
    // app.use(bodyParser.json())
app.use(favicon(__dirname + '/favicon.ico'));

app.use(compression())
app.set('view engine', 'ejs')

app.use(express.static('public'))

app.get('/', (req, res) => {
    res.render('index', { url: './js/selectCheckBox' })
})

app.post('/api/userInfo', (req, res) => {

    res.send('POST请求的数据提交过来了')
})
app.get('/api/userInfo', (req, res) => {
    res.send('GET请求的数据提交过来了')
})


// jQuery所有的案例的路由配置
app.use('/jquery', jqueryRouter);
app.use('/js', javascriptRouter);
app.use('/opp', oppRouter);
app.use('/video', videoRouter);
app.use('/ajax', ajaxRouter);
app.use('/api', exampleClassifyRouter);
app.use('/upload', uploadRouter);

app.listen(3000)